<template>  
    <ynet-content id="applyParam" :headerInformation="true" :headerMenu="true">
        <div>
            <el-form ref="form" :model="form" class="formEmbedTable mb20 mt20">
                <table>
                    <caption>A/C Information</caption>
                    <tr>
                        <td><div style="min-width:108px;text-align:center">Primary A/C No.</div></td> 
                        <td>
                            <el-form-item prop="primaryAcct">
                            <span>{{confirmMsg.acctNo}}</span>
                            </el-form-item>
                        </td>
                        <td><div style="min-width:64px;text-align:center">A/C Type</div></td> 
                        <td>
                            <el-form-item prop="subType">
                            <div style="min-width:60px" v-if="confirmMsg.subType == 'P'">Savings</div>
                            <div style="min-width:60px" v-if="confirmMsg.subType == 'S'">Time deposit</div>
                            </el-form-item>
                        </td>
                    </tr>

                    <tr v-for="(item,index) in confirmMsg.relatedAcctList">
                        <td><div style="min-width:108px;text-align:center">A/C No.</div></td> 
                        <td>
                            <el-form-item prop="relatedAcct">
                            <span>{{confirmMsg.relatedAcctList[index].acctNo.value}}</span>
                            </el-form-item>
                        </td>
                        <td><div style="min-width:64px;text-align:center">A/C Type</div></td> 
                        <td>
                            <el-form-item prop="subType">
                            <div style="min-width:60px" v-if="confirmMsg.relatedAcctList[index].subType.value == 'P'">Savings</div>
                            <div style="min-width:60px" v-if="confirmMsg.relatedAcctList[index].subType.value == 'S'">Time deposit</div>
                            </el-form-item>
                        </td>
                    </tr>
                </table>
            </el-form>

            <el-form ref="form" :model="form" class="formEmbedTable mb20">
                <table>
                    <caption>CUS Information</caption>
                    <tr>
                        <td>CUS.ID</td>
                        <td>
                            <span class="cOrange">{{confirmMsg.cusID}}</span>
                        </td>
                    </tr>   
                    <!--<tr v-for="legal in confirmMsg.cstInfo.legalList">
                        <td>CNTY</td>
                        <td>
                            <span class="cOrange">{{legal.cnty}}</span>
                        </td>
                        <td>Document Type</td>
                        <td>
                            <span class="cOrange">{{legal.docType}}</span>
                        </td>
                        <td>Document Number</td>
                        <td>
                            <span class="cOrange">{{legal.docNo}}</span>
                        </td>
                    </tr>-->
                </table>
            </el-form>

            <el-form ref="form" :model="form" class="formEmbedTable mb20">
                <table>
                    <tr>
                        <td>A/C Address</td>
                        <td>
                            <span class="cOrange">{{confirmMsg.acc_addr1}} {{confirmMsg.acc_addr2}} {{confirmMsg.acc_addr3}} {{confirmMsg.acc_addr4}}</span>
                        </td>
                    </tr>
                    <tr>
                        <td>ADDR.COUNTRY</td>
                        <td>
                            <span class="cOrange">{{confirmMsg.addr_cntry_code}}</span>
                        </td>
                    </tr>
                    <tr>
                        <td>Authorized Person</td>
                        <td>
                            <el-form-item>
                            <span class="cOrange">{{confirmMsg.authorPerson}}</span>
                            </el-form-item>
                        </td>
                    </tr>
                </table>
            </el-form>
            <div class="btnArea mt20 tac">
                <el-button type="primary" @click="agree()">Approve</el-button>
                <el-button type="primary" @click="rules()">Reject</el-button>
                <el-button type="primary" icon="close" @click="back">Back</el-button>
            </div>
        </div>
        <el-dialog :visible.sync="dialogTableVisible" :close-on-click-modal="false" :close-on-press-escape="false">
            <el-form ref="rejectForm" :model="rejectForm" class="formEmbedTable">
                <table>
                    <caption>Refusal reason</caption>
                    <tr>
                        <td>Refusal reason</td>
                        <td>
                            <el-form-item prop="rejReason">
                                <el-input placeholder="Refusal reason" v-model="rejectForm.rejReason"></el-input>
                            </el-form-item>
                        </td>
                    </tr>
                </table>
                <div class="btnArea mt20 tac">
                    <el-button type="primary" @click="dialogTableVisible = false,reject()">Confirm</el-button>
                </div>
            </el-form>
        </el-dialog>
    </ynet-content>
</template>

<script>
	export default {
		name:'IM0401Detail',
        props:['detailData','toDetail'],
		components:{
		},
		data(){
            return { 
               confirmMsg:{},
               rejectForm:{//审核拒绝列表
                    bsnAuthList:[],authFlag:'1',rejReason:'',
                },
                agreeForm:{
                    bsnAuthList:[],authFlag:'0',
                },
                dialogTableVisible:false,
            }   
        },
		methods:{ 
            back(){
                this.$emit('back')
            },
            rules(){//判断是否选中数据
               this.dialogTableVisible=true;
            },
            agree(){
               //判断是否选中数据
               console.log("toDetail"+JSON.stringify(this.toDetail))
                this.agreeForm.bsnAuthList.push(this.toDetail);
                console.log("agreeForm"+JSON.stringify(this.agreeForm))
                this.$tools.request(this,this.toDetail.bsnCode+"AuthAction.do",this.agreeForm).then(data=>{
                    if(data.body.errorCode==0){
                        this.$message({
                            type:'success',
                            message:'Success',
                            showClose:true,
                        })
                        this.$emit("back")
                    }else{
                        this.$alert("System Error Try again", "warning",{
                            confirmButtonText: 'Confirm',
                            callback: action => {
                            }
                        })
                    }
                })
            },
            reject(){
                this.rejectForm.bsnAuthList.push(this.toDetail);
                console.log("rejectForm"+JSON.stringify(this.rejectForm))
                this.$tools.request(this,this.toDetail.bsnCode+"AuthAction.do",this.rejectForm).then(data=>{
                    if(data.body.errorCode==0){
                        this.$message({
                            type:'success',
                            message:'Success',
                            showClose:true,
                        })
                        this.$emit("back")
                    }else{
                        this.$alert("System Error Try again", "warning",{
                            confirmButtonText: 'Confirm',
                            callback: action => {
                            }
                        })
                    }
                })
            },
		},
        mounted(){
            let _this = this
            _this.confirmMsg = _this.detailData
        }
	}
</script>